

#include "game_engine.h"
#include "utility.h"


int Init()
{
    //Initialize all SDL subsystems
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        log_error("Couldn't initialize SDL");
        return 1;
    }
    
    if (Mix_Init( MIX_INIT_OGG ) != MIX_INIT_OGG)
    {
        log_error("Couldn't initialize SDL_mixer");
        return 1;
    }
    
	if (Mix_OpenAudio(AUDIO_RATE, AUDIO_FORMAT, AUDIO_CHANNELS, AUDIO_BUFFERS))
	{
		log_error("Couldn't open audio device.");
		return 1;
	}

	return 0;
}

void Shutdown()
{
	//Close audio device
	Mix_CloseAudio();
    //Shut down sdl
    SDL_Quit();

}

int main( int argc, char* args[] )
{
    GameEngine engine;

	Init();

	int retVal = engine.Run();
    
	Shutdown();

	return retVal;
}